package com.pdsu.graduation_design.listener;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.pdsu.graduation_design.R;
import com.pdsu.graduation_design.dto.PayCommodityDTO;

//支付页面点击商品加 , 减 按钮监听
public class PayListItemButtonListener implements View.OnClickListener {
    private Button add_btn,del_btn;
    private Context context;
    private View view;
    private boolean isChecked;
    private TextView all_pr;
    private PayCommodityDTO commodity;

    public PayListItemButtonListener(Button add_btn, Button del_btn, Context context, View view, boolean isChecked, TextView all_pr, PayCommodityDTO commodity) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
        this.context = context;
        this.view = view;
        this.isChecked = isChecked;
        this.all_pr = all_pr;
        this.commodity = commodity;
    }

    public PayListItemButtonListener(Button add_btn, Button del_btn, Context context, View view, boolean isChecked, TextView all_pr) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
        this.context = context;
        this.view = view;
        this.isChecked = isChecked;
        this.all_pr = all_pr;
    }

    public PayListItemButtonListener(Button add_btn, Button del_btn, Context context, View view, boolean isChecked) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
        this.context = context;
        this.view = view;
        this.isChecked = isChecked;
    }

    public PayListItemButtonListener(Button add_btn, Button del_btn, Context context, View view) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
        this.context = context;
        this.view = view;
    }

    public PayListItemButtonListener() {
    }

    public PayListItemButtonListener(Button add_btn, Button del_btn) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
    }

    public PayListItemButtonListener(Button add_btn, Button del_btn, Context context) {
        this.add_btn = add_btn;
        this.del_btn = del_btn;
        this.context = context;
    }

    @Override
    public void onClick(View v) {

        TextView textView= view.findViewById(R.id.pay_number);
        int n=Integer.valueOf(textView.getText().toString());
        Double all_p=Double.valueOf(all_pr.getText().toString());

        if (v==add_btn){

            System.out.println("is checked"+isChecked);
            System.out.println("is checked"+isChecked);
            textView.setText(n+1+"");
            if (isChecked){

//                int sig= Integer.parseInt(commodity.getName());
//                all_pr.setText(all_p+sig*1.0+"");

            }
            System.out.println("add");

        }else {


            textView.setText(n-1+"");
            System.out.println("del");
            if (isChecked){

                System.out.println("是");
//                int sig= Integer.parseInt(commodity.getName());
//                all_pr.setText(all_p-sig*1.0+"");
            }
        }


    }
}
